//
//  NSString+ClearPPPP.m
//  diaoyuren
//
//  Created by 钓鱼人 on 16/1/18.
//  Copyright © 2016年 game. All rights reserved.
//

#import "NSString+ClearPPPP.h"

@implementation NSString (ClearPPPP)
-(NSString *)ClearPPP{

 
    NSString *strr =  [self substringFromIndex:[self rangeOfString:@"<p>"].location+[self rangeOfString:@"<p>"].length];

    strr =[strr stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
   
    return [NSString stringWithFormat:@"\t%@",strr];
}


-(NSString *)ClearStrong{
    
    NSRange range = [self rangeOfString:@"</strong>"];

    NSString *yyy = [self substringToIndex:self.length-range.length];
    
    NSRange range2 = [yyy rangeOfString:@"<strong>"];
    
    NSString *zzz;
    if (range2.length !=0) {
        zzz = [yyy substringFromIndex:range2.location+range.length-1];
    }else{
    
        zzz = yyy;
    }
    
    return zzz;
    
}

-(NSString *)ClearhSimpStrong{
    
    NSString *strr =  [self substringFromIndex:[self rangeOfString:@"<strong>"].location+[self rangeOfString:@"<strong>"].length];
    
    strr =[strr stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
    
    
    return strr;
}

-(NSString *)Clearh1111{
    
    
    NSString *strr =  [self substringFromIndex:[self rangeOfString:@"<h1>"].location+[self rangeOfString:@"<h1>"].length];
    
    strr =[strr stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
    
    
    return strr;
}



-(NSString *)Clearh2222{
    
    
    NSString *strr =  [self substringFromIndex:[self rangeOfString:@"<h2>"].location+[self rangeOfString:@"<h2>"].length];
    
    strr =[strr stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
        
    return strr;
}


-(NSString *)Clearh3333{
    
    
    NSString *strr =  [self substringFromIndex:[self rangeOfString:@"<h3>"].location+[self rangeOfString:@"<h3>"].length];
    
    strr =[strr stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
    
    return strr;
}

-(NSString *)Clearh4444{
    
    
    NSString *strr =  [self substringFromIndex:[self rangeOfString:@"<h4>"].location+[self rangeOfString:@"<h4>"].length];
    
    strr =[strr stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
    
    
    return strr;
}

-(NSString *)Clearh5555{
    
    
    NSString *strr =  [self substringFromIndex:[self rangeOfString:@"<h5>"].location+[self rangeOfString:@"<h5>"].length];
    
    strr =[strr stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

    
    return strr;
}

-(NSString *)Clearh6666{
    
    
    NSString *strr =  [self substringFromIndex:[self rangeOfString:@"<h6>"].location+[self rangeOfString:@"<h6>"].length];
    
    strr =[strr stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
    
    
    return strr;
}


-(NSString *)ClearPTo000{
    
    NSArray *ary = @[@"</p>",@"<p>"];
    
    NSString *text= self;
    for (int i =0; i<ary.count; i++) {
        NSError* error = NULL;
        
        NSRegularExpression* regex = [NSRegularExpression regularExpressionWithPattern:ary[i]
                                                                               options:0
                                                                                 error:&error];
        text = [regex stringByReplacingMatchesInString:text
                                               options:0
                                                 range:NSMakeRange(0, text.length)
                                          withTemplate:@""];
        text = [text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
        
        text = [NSString stringWithFormat:@"\t%@",text];
        
    }
    
    return text;

}


@end
